{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="__PUBLIC__/css/style.min862f.css" rel="stylesheet">
{/block}
{block name="js"}
<script src="__PUBLIC__/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript">
    $(".db-import").click(function(){
        var self = this, status = ".";
        $.get(self.href, success, "json");
        window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
        return false;

        function success(data){
            if(data.status == 'y'){
                if(data.data.gz){
                    data.info += status;
                    if(status.length === 5){
                        status = ".";
                    } else {
                        status += ".";
                    }
                }
                $(self).parent().prev().text(data.info);
                if(data.data.part){
                    $.get(self.href,
                            {"part" : data.data.part, "start" : data.data.start},
                            success,
                            "json"
                    );
                }  else {
                    window.onbeforeunload = function(){ return null; }
                }
            } else {
                alert(data.info,'alert-error');
            }
        }
    });
</script>
{/block}
{block name='body'}

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>数据库备份</h5>
						<a href="{:url('add')}" class="btn btn-sm btn-primary pull-right m-t-n-xs">添加备份</a>
                    </div>
                    <div class="ibox-content">
						
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>备份名称</th>
                                    <th>卷数</th>
                                    <th>压缩</th>
                                    <th>数据大小</th>
                                    <th>备份时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
								{foreach name="list" item="li"}
                                    <tr>
                                        <td>{$li.time|date='Ymd-His',###}</td>
                                        <td>{$li.part}</td>
                                        <td>{$li.compress}</td>
                                        <td>{$li.size|format_bytes}</td>
                                        <td>{$key}</td>
                                        <td>正常</td>
                                        <td class="action">
											<a href="{:url('import?time='.$li['time'])}" class="btn btn-primary btn-xs edit db-import"><i class="fa fa-reply"></i> 还原数据</a>
											<a href="/{:config('db.DATA_BACKUP_PATH')}{$li.title}" class="btn btn-primary btn-xs edit"><i class="fa fa-download"></i> 下载</a>
											<a href="javascript:;" onclick="del('{$li.time}');" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
                                        </td>
                                    </tr>
								{/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        
    </div>
</body>
{/block}